Skip to content

drivers: Standardize continuous and one-shot mode method naming.#163

Merged
nedseb merged 1 commit intomainfrom
fix/standardize-continuous-oneshot
Mar 16, 2026
Merged

drivers: Standardize continuous and one-shot mode method naming.#163
nedseb merged 1 commit intomainfrom
fix/standardize-continuous-oneshot

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 16, 2026

Closes #81

Summary

Standardize continuous/one-shot mode methods across all drivers.

Convention:

  • set_continuous(odr) — start continuous measurements at given rate
  • trigger_one_shot() — trigger a single conversion
  • read_one_shot() — trigger + wait + return data

Changes

Driver Before After
wsen-hids set_continuous_mode(odr) set_continuous(odr)
hts221 set_odr() only + set_continuous(odr), read_one_shot()
lis2mdl set_mode("continuous") only + set_continuous(hz), trigger_one_shot(), read_one_shot()

Final state

Driver set_continuous() trigger_one_shot() read_one_shot()
hts221
lis2mdl
wsen-hids
wsen-pads

Not applicable to ISM330DL (always continuous), APDS9960 (enable/disable model), VL53L1X (start/stop ranging), BQ27441/MCP23009E/SSD1327 (no conversion modes).

Also updated README and examples.

Test plan

ruff check lib/                          # All checks passed
python3 -m pytest tests/ -k "mock" -v    # 115 passed

@nedseb nedseb self-assigned this Mar 16, 2026
@nedseb nedseb added the enhancement New feature or request label Mar 16, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58f4d3b543

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/hts221/hts221/device.py
@nedseb nedseb force-pushed the fix/standardize-continuous-oneshot branch from 58f4d3b to e434a59 Compare March 16, 2026 09:47
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e434a59f63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/lis2mdl/lis2mdl/device.py Outdated
Comment thread lib/hts221/hts221/device.py Outdated
@nedseb nedseb force-pushed the fix/standardize-continuous-oneshot branch from e434a59 to d93ab6c Compare March 16, 2026 09:52
@nedseb nedseb requested a review from Copilot March 16, 2026 09:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes driver APIs for continuous vs one-shot measurement modes by converging on a common set of method names (set_continuous, trigger_one_shot, read_one_shot) across multiple sensor drivers, and updates related docs/examples/tests accordingly.

Changes:

  • Renames WSEN-HIDS continuous-mode entrypoint to set_continuous(odr) and updates its examples.
  • Adds standardized continuous/one-shot helpers to HTS221 and LIS2MDL drivers.
  • Extends YAML scenario tests and updates the root README to document the new “mode methods” convention.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/scenarios/wsen_hids.yaml Adds scenario coverage for set_continuous() enabling the sensor.
tests/scenarios/lis2mdl.yaml Adds scenarios validating continuous/one-shot helpers are callable and write expected registers.
tests/scenarios/hts221.yaml Adds scenarios for set_continuous() enabling sensor and read_one_shot() return types.
lib/wsen-hids/wsen_hids/device.py Renames set_continuous_mode() to set_continuous().
lib/wsen-hids/examples/full_test.py Updates example usage/output strings to new method name.
lib/wsen-hids/examples/continuous_mode.py Updates example usage to set_continuous().
lib/lis2mdl/lis2mdl/device.py Adds set_continuous(), trigger_one_shot(), read_one_shot().
lib/hts221/hts221/device.py Adds set_continuous() and read_one_shot().
README.md Documents standardized mode-method naming convention.
Comments suppressed due to low confidence (1)

lib/wsen-hids/wsen_hids/device.py:193

  • set_continuous_mode() was renamed to set_continuous(), which is a breaking public API change. Consider keeping set_continuous_mode as a deprecated alias that forwards to set_continuous (at least for one release) to avoid breaking existing users and downstream examples/docs.
    def set_continuous(self, odr=ODR_1_HZ):
        if odr not in (ODR_1_HZ, ODR_7_HZ, ODR_12_5_HZ):
            raise ValueError("Invalid ODR for continuous mode")

        ctrl1 = self._read_reg(REG_CTRL_1)
        ctrl1 |= CTRL_1_PD
        ctrl1 &= ~CTRL_1_ODR_MASK
        ctrl1 |= odr
        self._write_reg(REG_CTRL_1, ctrl1)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/hts221/hts221/device.py Outdated
Comment thread lib/lis2mdl/lis2mdl/device.py
Comment thread README.md
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d93ab6c0fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/wsen-hids/wsen_hids/device.py
@nedseb nedseb force-pushed the fix/standardize-continuous-oneshot branch from d93ab6c to bf57b26 Compare March 16, 2026 09:58
@nedseb nedseb merged commit 654b486 into main Mar 16, 2026
3 checks passed
@nedseb nedseb deleted the fix/standardize-continuous-oneshot branch March 16, 2026 10:02
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drivers: Standardize continuous/one-shot mode method naming.

2 participants